package com.markus.basic.设计模式.动态代理模式.jdk动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Author:markusZhang
 * Date:Create in 2020/8/30 14:44
 * todo:
 */
public class Client {
    public static void main(String[] args) {
        RealImage realImage = new RealImage("高清.jpg");
        InvocationHandler invocationHandler = new MyInvocationHandler(realImage);
        Image image = (Image) Proxy.newProxyInstance(RealImage.class.getClassLoader(), RealImage.class.getInterfaces(), invocationHandler);
        image.display();
        RealVideo realVideo = new RealVideo("奥特曼");
        InvocationHandler invocationHandler1 = new MyInvocationHandler(realVideo);
        Video video = (Video) Proxy.newProxyInstance(RealVideo.class.getClassLoader(), RealVideo.class.getInterfaces(), invocationHandler1);
        video.display();
    }
}
